<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">    
    <title>My JSP 'boollist.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" type="text/css" href="css/common.css">
  </head>
  
  <body>
    <div id="admin_bookselect">
    	<s:form action="jsp_admin_bookselect.action" method="post" theme="simple">
    		<s:hidden name="curPos" value="%{curPos}"></s:hidden>
    		<table id="searchpart">
    			<tr>
    				<td>分类检索：</td>
    				<td><s:select name="typeId" list="%{typeList}" listKey="typeId" listValue="typeName" onchange="this.form.submit();"></s:select></td>
    				<td>关键字检索：</td>
    				<td><s:textfield name="keyword"></s:textfield></td>
    				<td><s:submit value="搜索"></s:submit></td>
    			</tr>
    		</table>
    		<table class="tablestyle">
    			<tr class="table_title">
    				<th>图书名称</th><th>作者</th><th>类型</th><th>单价</th><th>总数量</th><th>剩余数量</th><th>处理</th>
    			</tr>
    			<s:iterator value="%{bookList}">
		    		<tr>
		    			<td align="center"><s:property value="title" /></td>
		    			<td align="center"><s:property value="author" /></td>
		    			<td align="center"><s:property value="typeName" /></td>
		    			<td align="center"><s:property value="price" /></td>
		    			<td align="center"><s:property value="totalAmount" /></td>
		    			<td align="center"><s:property value="remainder" /></td>
		    			<td align="center">
		    				<a href="jsp_admin_bookdetail.action?bookId=<s:property value='bookId' />">详情</a>
		    				<a href="jsp_admin_bookdelete.action?bookId=<s:property value='bookId' />">删除</a>
		    			</td>
		    		</tr>
	    		</s:iterator>
	    		<s:if test="%{cnt==0}">
	    			<tr>
	    				<td colspan="7">没有图书</td>
	    			</tr>
	    		</s:if>
	    		<s:else>
		    		<tr>
		    			<td colspan="4">共检索到<s:property value="cnt"/>条记录</td>
		    			<td colspan="3">
		    				共<s:property value="%{cnt/5+(cnt%5!=0?1:0)}"/>页
		    				当前第<s:property value="%{curPos/5+1}" />页
		    				<s:if test="%{curPos!=1}">							
		    					<a href="jsp_admin_bookselect.action?curPos=1&typeId=<s:property value='%{typeId}' />">首页</a>
		    					<a href="jsp_admin_bookselect.action?curPos=<s:property value='%{curPos-5}' />&typeId=<s:property value='%{typeId}' />">上一页</a>
		    				</s:if>
		    				<s:else>
		    					首页 上一页
		    				</s:else>
		    				<s:if test="%{curPos!=nextPos}">	    							   	    				
		    					<a href="jsp_admin_bookselect.action?curPos=<s:property value='%{nextPos}' />&typeId=<s:property value='%{typeId}' />">下一页</a>
		    					<a href="jsp_admin_bookselect.action?curPos=<s:property value='%{cnt-cnt%5+1}' />&typeId=<s:property value='%{typeId}' />">尾页</a>
		    				</s:if>
		    				<s:else>
		    					下一页 尾页
		    				</s:else>
		    			</td>		    		
		    		</tr>	    		
	    		</s:else>
    		</table>
    	</s:form>
    </div>
  </body>
</html>
